package Offer042;

import java.util.LinkedList;
import java.util.Queue;

/**
 * 最近请求次数
 *
 * @author 23737
 * @time 2021.12.19
 */
public class Test {
    public static void main(String[] args) {

    }
}

/**
 * Queue
 */
class RecentCounter {
    Queue<Integer> queue;

    public RecentCounter() {
        queue = new LinkedList<>();
    }

    public int ping(int t) {
        queue.offer(t);
        while (queue.peek() < t - 3000) {
            queue.poll();
        }
        return queue.size();
    }
}
